package com.s7_widgets.adapter;

import android.view.View;
import android.widget.ImageView;

import com.s7.widget.banner.holder.BannerHolder;
import com.s7.widget.banner.holder.CBViewHolderCreator;
import com.s7_widgets.MyApp;
import com.s7_widgets.R;

public class BannerAdapter implements CBViewHolderCreator {

    @Override
    public BannerHolder createHolder(View itemView) {
        return new LocalImageHolderView(itemView);
    }

    @Override
    public int getLayoutId() {
        return R.layout.banner_item;
    }

    public static class LocalImageHolderView extends BannerHolder<String> {

        private ImageView mImage;

        public LocalImageHolderView(View itemView) {
            super(itemView);
        }

        @Override
        protected void initView(View itemView) {
            mImage = itemView.findViewById(R.id.banner_image);
        }

        @Override
        public void updateUI(String data) {
            MyApp.getInstance().setImage(data, mImage);
        }
    }
}
